import { createApp } from 'vue';
// @ts-ignore
import App from './App.vue';

const app = createApp(App);

// 引入重置样式
import './style/reset.scss';
// 一定要在main.ts中导入tailwind.css，防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
import './style/tailwind.css';
import 'element-plus/dist/index.css';
// 引入Element-plus
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// svg 相关
import 'virtual:svg-icons-register';
// @ts-ignore
import ReSvg from './components/ReSvg/index.vue';
// 暗黑模式
import 'element-plus/theme-chalk/dark/css-vars.css';
// 国际化
import i18n from '@/locales/index.ts';
// 引入 motion 动画
import { MotionPlugin } from '@vueuse/motion';
// pinia
import { setupStore } from '@/store';
// router
import { setupRouter } from '@/router';
//引入echarts
import * as echarts from 'echarts';
app.config.globalProperties.$echarts = echarts;
// 循环滚动
import vue3SeamlessScroll from 'vue3-seamless-scroll';

// 全局注册使用 element plus 的图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component);
}

const setupApp = async () => {
	const app = createApp(App);

	// store
	setupStore(app);

	// 创建路由
	setupRouter(app);

	app.component('svg-icon', ReSvg);

	app.use(vue3SeamlessScroll, {
		name: 'vue3SeamlessScroll'
	});

	app.use(i18n);

	app.use(MotionPlugin);

	app.mount('#app');
};

setupApp();
